﻿using System;
using System.Windows.Forms;
using GedcomReader;
using WindowsFormsApplication1;

namespace GenoSharp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string path = @"C:\document1.ged";
            string outpath = @"C:\document1.txt";
            Gedcom GD = new Gedcom(path);

            string[] options = { "ratio=auto"};
            GraphvizWriter GVW = new GraphvizWriter("Family Tree",options);
            foreach (Individual I in GD.Individuals)
            {
                string color = "pink";
                if (I.Sex == "M")
                {
                    color = "blue";
                }
                GVW.ListNode(I.ID, I.Name, "filled", color, "box");
                
                //foreach (string S in I.AllFamC)
                //{
                //    GVW.ConnNode(S, I.ID);
                //}
                //foreach (string S in I.AllFamS)
                //{
                //     GVW.ConnNode(I.ID, S);
                //}
            }
            foreach (Pedigree P in GD.Pedigrees)
            {
                if (P.Pedigree_Type.Contains("parent"))
                {
                    GVW.ConnNode(P.IndividualID,P.FamilyID);
                }
                else if (P.Pedigree_Type.Contains("biological"))
                {
                    GVW.ConnNode(P.FamilyID,P.IndividualID);
                }
            }

            //foreach (Family F in GD.Families)
            //{
            //    if (F.Type == "PAR")
            //    {
            //        GVW.ConnNode(F.IndiID, F.FamID);
            //    }
            //    else if (F.Type == "CHIL")
            //    {
            //        GVW.ConnNode(F.FamID, F.IndiID);
            //    }
            //}
            
            GVW.SaveFile(outpath);
            MessageBox.Show("done");
        }
    }
}
